﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucCap.ascx.cs" Inherits="STT.Admin.UserControls.ucCap" %>

<%--<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">--%>
<%--<ContentTemplate>--%>
<div id="content-header">
    <div id="breadcrumb">
        <a href="../Admin/Default.aspx?idpage=1" class="tip-bottom" data-original-title="Về bảng điều khiển">
            <i class="icon-home"></i>Trang chính
        </a>
        <a href="../Admin/Default.aspx?" class="current">Quản lý dữ liệu</a>
        <a href="../Admin/Default.aspx?" class="current">Quản lý Cấp</a>
    </div>
</div>

<div class="widget-box">
    <div class="widget-title">
        <span class="icon"><i class="icon-th"></i></span>
        <h5>Danh sách các Cấp</h5>

        <div id="search">
            <asp:TextBox ID="txtTimKiem" runat="server" placeholder="Nhập từ tìm kiếm..."></asp:TextBox>
            <button class="tip-left" data-original-title="Tìm kiếm">
                <asp:ImageButton ID="btSearch" runat="server" ImageUrl="~/img/icon-search.png" OnClick="btSearch_Click" />
            </button>
        </div>
    </div>

    <div class="widget-content nopadding">
        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper" role="grid">
            <asp:GridView ID="gvCap" runat="server" CssClass="table table-bordered table-hover"
                AutoGenerateColumns="False" DataKeyNames="MaCap"
                OnRowCancelingEdit="gvCap_RowCancelingEdit"
                OnRowDeleting="gvCap_RowDeleting"
                OnPageIndexChanging="gvCap_PageIndexChanging" EnableViewState="False"
                OnRowCommand="gvCap_RowCommand" AllowPaging="True" PageSize="20">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <%-- Bắt sự kiện nhấn cbChonTat --%>
                            <asp:CheckBox ID="cbChonTat" runat="server" onclick="cbChonTat(this);" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <%-- Bắt sự kiện nhấn cbChon --%>
                            <asp:CheckBox ID="cbChon" runat="server" onclick="cbChon(this);" />
                        </ItemTemplate>
                        <ItemStyle Width="10px" HorizontalAlign="Center"></ItemStyle>
                    </asp:TemplateField>
                   
                    <asp:BoundField DataField="TenCap" HeaderText="Tên Cấp"
                        SortExpression="TenCap" ItemStyle-CssClass="span2">
                        <ItemStyle CssClass="span2"></ItemStyle>
                    </asp:BoundField>

                    <asp:TemplateField HeaderText="Trạng thái" SortExpression="TrangThai">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("TrangThai") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblTrangThai" runat="server" Text='<%# Eval("TrangThai").ToString().Trim()=="1"?"Sử dụng":"Không sử dụng" %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle CssClass="span2" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Sửa" ShowHeader="False">
                        <ItemTemplate>
                            <%-- Bắt sự kiện nhấn nút sửa --%>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
                                Text="Sửa" CommandName="ChonSua" CommandArgument="<%#((GridViewRow)Container).RowIndex%>">
                                <img src="../../img/edit.jpg" alt="Alternate Text" />
                            </asp:LinkButton>
                        </ItemTemplate>
                        <ItemStyle CssClass="span1" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Xóa" ShowHeader="False">
                        <ItemTemplate>
                            <%-- Bắt sự kiện nhấn nút xóa --%>
                            <asp:LinkButton ID="LinkButton2" runat="server" type="submit" CommandName="Delete"
                                OnClientClick="return ConfirmDelete('Có chắc bạn muốn xóa?');" CausesValidation="false">
                                <img src="../../img/delete.jpg" alt="Alternate Text" />
                            </asp:LinkButton>

                        </ItemTemplate>
                        <ItemStyle CssClass="span1" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

            <div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-bl">

                <asp:LinkButton ID="lbXoaTat" runat="server" CssClass="btn" OnClientClick="return ConfirmDelete('Có chắc bạn muốn xóa các dòng đã chọn?');"
                    OnClick="lbXoaTat_Click" CausesValidation="false">Xóa chọn</asp:LinkButton>

                <div class="btn-group">
                    <a href="#thongTin" data-toggle="modal" id="btThem">
                        <button class="btn"  id="change" >
                            Thêm mới</button>
                    </a>

                </div>

                <asp:HyperLink ID="HyperLink2" CssClass="btn" Target="_blank" runat="server" NavigateUrl="~/Report/ViewCap.aspx">                        
                            Xuất dữ liệu
                </asp:HyperLink>

            </div>
        </div>
    </div>
</div>
<asp:HiddenField ID="hfMaCap" runat="server" />
<div class="validatecontrol">

    <div id="thongTin" class="modal hide" aria-hidden="true" style="display: none;">
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">×</button>
            <h3 runat="server" id="txtTieuDe" class="username">Thêm Cấp mới</h3>
        </div>
        <div class="modal-body">
            <div class="control-group">
                <label class="control-label">Tên Cấp: </label>
                <div class="controls">
                    <asp:TextBox ID="txtTenCap" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvTen" runat="server" ControlToValidate="txtTenCap"
                        ErrorMessage="*" ToolTip="Bạn chưa nhập họ của bạn" ForeColor="Red" Font-Bold="true"></asp:RequiredFieldValidator>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Trạng thái: </label>
                <div class="controls">
                    <asp:DropDownList ID="ddlTrangThai" runat="server">
                        <asp:ListItem Text="Sử dụng" Selected="True" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Không sử dụng" Value="0"></asp:ListItem>
                    </asp:DropDownList>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <asp:Button ID="btThemMoi" runat="server" CssClass="btn btn-primary btValidate" Text="Thêm mới"
                OnClick="btThemMoi_Click" />
            <asp:Button ID="btSua" runat="server" CssClass="btn btn-primary btValidate" Text="Lưu"
                OnClick="btSua_Click" />
            <a data-dismiss="modal" class="btn" href="#" id="cancel">Hủy</a>
        </div>

    </div>
</div>
<div id="themFileExcel" class="modal hide" aria-hidden="true" style="display: none;">
    <div class="modal-header">
        <button data-dismiss="modal" class="close" type="button">×</button>
        <h3 runat="server" id="H1">Thêm từ file Excel</h3>
    </div>
    <div class="modal-body">
        <asp:FileUpload ID="FileUpload1" runat="server" />
    </div>
    <div class="modal-footer">
        <asp:Button ID="btThemExcel" runat="server" CssClass="btn btn-primary btValidate"
            Text="Thêm"
            OnClick="btThemExcel_Click" CausesValidation="false" />
        <a data-dismiss="modal" class="btn" href="#">Hủy</a>
    </div>
</div>

<script>
    $(document).ready(function () {
        $("#change").click(function (event) {
            $('.username').html("Thêm cấp");
        });
    });
    $(document).ready(function () {
        $('.btValidate').click(function () {
            $('form').quickValidate();
        });

        if ('<%Response.Write(chonSuaClick.ToString());%>' == 'True') {
                    $('#btThem').click();
                    $('#<%=btThemMoi.ClientID%>').css('display', 'none');
            $('#<%=btSua.ClientID%>').css('display', 'inline-block');
                }

                $('#btThem').click(function () {
                    $('#thongTin').find('input:not([type=submit])').val('');
                    $('#<%=btThemMoi.ClientID%>').css('display', 'inline-block');
            $('#<%=btSua.ClientID%>').css('display', 'none');
        });
            });
</script>

<%--</ContentTemplate>--%>
<%--</asp:UpdatePanel>--%>
